<?php

class Request{
	public function session($key){
		if($key){
			return $_SESSION[$key];
		}	
		return $_SESSION; 
	}
	public function cookie($key=0){
		if($key){
			return $_COOKIE[$key];

		}	
		return $_COOKIE; 
	}
	public function post($key=""){
		if($key){
			return $_POST[$key];
		}
		return $_POST ; 
	}
	function get($key=""){
		$arr = explode('/',$_SERVER["PATH_INFO"]);
		unset($arr[0],$arr[1],$arr[2],$arr[3]);
		$arr = array_values($arr);
		
		$num = count($arr)/2;
		
		$new = [];
		for($i=0;$i<$num;$i++){
			$new[$arr[$i*2]] = $arr[$i*2+1];
		}
		
		$arr = array_merge($new,$_GET);
		
		if($key){
			return $arr[$key];
		}else{
			return $arr;
		}
	}

}